package BasicClass.Two;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Two6 {
    public static void main(String[] args) throws IOException {
        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
        int size = Integer.parseInt(reader.readLine());
        String[] nums = reader.readLine().split(" ");
        int[] arr = new int[size];
        for (int i = 0; i < size; i++) {
            arr[i]=Integer.parseInt(nums[i]);
        }
        Two6 one20 = new Two6();
        int[] main = one20.Main(arr, 0, arr.length - 1);
        StringBuilder builder = new StringBuilder();
        for (int i : main) {
            builder.append(i+" ");
        }
        System.out.println(builder);
    }

    /**
     * 给你一个n代表有n个数字，然后你需要使用归并排序将这些数字从小到大排好。
     * @param arr
     * @return
     */
    public int[] Main(int[] arr,int left,int right){
        if(left==right){
            return new int[]{arr[left]};
        }
        int mid = left+((right-left)>>1);
        int[] lArr = Main(arr, left, mid);
        int[] rArr = Main(arr, mid+1, right);
        int[] helper = helper(lArr, rArr);
        return helper;
    }

    public int[] helper(int[] lArr,int[] rArr){
        int[] arr = new int[lArr.length + rArr.length];
        int pLeft = 0;
        int pRight = 0;
        int index = 0;
        while (pLeft<lArr.length && pRight<rArr.length){
            arr[index++] = lArr[pLeft]<rArr[pRight]?lArr[pLeft++]:rArr[pRight++];
        }
        while (pLeft<lArr.length){
            arr[index++] = lArr[pLeft++];
        }
        while (pRight<rArr.length){
            arr[index++] = rArr[pRight++];
        }
        return arr;
    }
}
